<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 1.  .stop修饰符的使用:阻止冒泡 -->
    <div @click="div1Click">
      divdiv
      <button @click.stop='btn1Click'>stop</button>
    </div>

    <hr>

    <!-- 2. .prevent修饰符的使用:阻止默认事件 -->
    <form action="baidu">
      <input type="submit" @click.prevent="submitClick">
    </form>

    <!-- 3. .监听某个键盘键的点击 -->
    <input type="text" @keyup.enter="keyUp">

    <!-- 4. .native 监听组件根元素的原生事件 -->
    <!-- <cpn @click.native="cpnClick"></cpn> -->

    <hr>

    <!-- 5. .once修饰符的使用:只触发一次 -->
    <button @click.once="btn2Click">once</button>
  </div>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {
        div1Click() {
          console.log('div1Click');
        },
        btn1Click() {
          console.log('btn1Click');
        },
        submitClick() {
          console.log('submitClick');
        },
        keyUp() {
          console.log('keyUp');
        },
        btn2Click() {
          console.log('btn2Click');
        }

      }
    });
  </script>
</body>

</html>